<template>
  <div class="container">
    <el-form label-position="left" ref="elForm" class="ml-3"
             :model="form"  size="medium" label-width="150px">
      <el-form-item label="设备型号">
        <!-- API field: deviceModel -->
        <input class="w-[330px]" v-model="form.deviceModel" type="text" disabled>
      </el-form-item>
      <el-form-item label="设备序列号">
        <!-- API field: serialNumber -->
        <input class="w-[330px]" v-model="form.serialNumber" type="text" disabled>
      </el-form-item>
      <el-form-item label="设备生产日期">
        <!-- API field: productDate -->
        <input class="w-[330px]" v-model="form.productionDate" type="text" disabled>
      </el-form-item>
      <el-form-item label="设备启动时间">
        <!-- API field: startTime -->
        <input class="w-[330px]" v-model="form.startTime" type="text" disabled>
      </el-form-item>
      <el-form-item label="主控版本">
        <!-- API field: softVersion -->
        <input class="w-[330px]" v-model="form.softVersion" type="text" disabled>
      </el-form-item>
      <el-form-item label="FPGA程序版本">
        <!-- API field: FPGAVersion -->
        <input class="w-[330px]" v-model="form.FPGAVersion" type="text" disabled>
      </el-form-item>
      <el-form-item label="测温算法版本">
        <!-- API field: tempAlgVersion -->
        <input class="w-[330px]" v-model="form.tempAlgVersion" type="text" disabled>
      </el-form-item>
      <el-form-item label="图像算法版本">
        <!-- API field: imageAlgVersion -->
        <input class="w-[330px]" v-model="form.imageAlgVersion" type="text" disabled>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

import {deviceinfo} from "@/api/api"; // Assuming correct path

export default {
  name: 'index',
  data() {
    return {
      // Initialize form with expected keys to avoid reactivity issues on first render
      form: {
        deviceModel: '',
        startTime: '', // Added based on API response field
        serialNumber: '',
        softVersion: '',
        masterVersion: '', // Kept for template, not in API response
        productionDate: '', // Added based on API response field
        hardVersion: '',
        tempAlgVersion: '',
        FPGAVersion: '',
        imageAlgVersion: ''
      },
    }
  },
  created() {
    deviceinfo().then(res => {
      // Using success code 200 as requested in the example logic
      if (res.code !== 0) {
        this.$message.error(res.msg || res.message || '获取设备信息失败'); // Check both msg/message
      } else {
        // Assign data, potentially overwriting initial structure if res.data is complete
        this.form = res.data;
      }
    })
  },
  methods: {
    // No additional methods needed based on request
  }
}
</script>

<style scoped>
.container {
  display: flex;
  flex-direction: column;
}

/* Keeping the original styles */

</style>
